<?php
/**
 * Created by PhpStorm.
 * User: mac
 * Date: 2021/3/15
 * Time: 11:01 PM
 */

namespace App\Factory\absfactory;


class OrderPizza
{
    public $absFactory = null;

    public function __construct(AbsFactory $absFactory)
    {
        $this->setFactory($absFactory);
    }

    public function setFactory(AbsFactory $absFactory)
    {
        $pizza = null;
        $this->absFactory = $absFactory;

        $orderType = 'cheese';
        // factory 可能是北京的工厂子类，也可能是伦敦的工厂子类
        $pizza = $this->absFactory->createPizza($orderType);
        if ($pizza != null) { // 订购ok
            $pizza -> prepare();
            $pizza -> bake();
            $pizza -> cut();
            $pizza -> box();
        } else {
            echo "订购失败";
        }

    }
}